import { getCurrentInstance, isVue2 } from 'vue-demi'

import type { Store } from 'vuex'

export const useStore = <T>(): Store<T> => {
  if (isVue2) {
    // @ts-ignore
    return getCurrentInstance()?.proxy?.$store as Store<T>
  }
  throw new Error('该hook只能在vue2环境使用')
}
